import request from "../utils/request";

// 登录
export const apiLogin = (data:{username: string, password: string}) =>{
    return request({
        url: '/api/login',
        method: "post",
        data
    })
}

// 获取用户信息
export const apigetUserInfo = () => {
    return request({
        url: '/api/getuserinfo',
    })
}

// 第三方登录
export const apiGiteeLogin = (data: {code: string}) => {
    return request({
        url: '/api/giteeLogin',
        method: 'post',
        data
    })
}

// 获取一级分类
export const apigetClassify = () => {
    return request({
        url: '/api/getClassify'
    })
}

// 二级分类
export const apigetClassifyTow = (data: {type: string}) => {
    return request({
        url: '/api/getClassifyTow',
        method: 'post',
        data
    })
}

// 获取列表数据
export const apigetList = (data: {value:string, towValue: string}) => {
    return request({
        url:'/api/getList',
        method: 'post',
        data
    })
}

// 获取类型的二级菜单
export const apigetClassifyList = () => {
    return request({
        url: '/api/getClassifyList'
    })
}

interface sendEditType {
    title: string,
    text: string,
    html: string,
    classify: string,
    classifytow: string,
    id: number,
    info: string,
    img: string
}

// 发布文章
export const apiSendEdit = (data:sendEditType) => {
    return request({
        url: '/api/sendEdit',
        method: 'post',
        data
    })
}

// 详情
export const apigetDetail = (data: {id: string}) => {
    return request({
        url: '/api/getDetail',
        method: 'post',
        data
    })
}

// 当前用户的文章
export const apigetUserArticle = () => {
    return request({
        url: '/api/gettUserArticle'
    })
}

// 关注
export const apiAttention = (data:any) => {
    return request({
        url: '/api/attention',
        method:'post',
        data
    })
}